/* 
 * File:   Sound.cpp
 * Author: agu
 * 
 * Created on 31 de mayo de 2014, 0:44
 */

#include "Sound.h"
#include "InitializationException.h"

Sound::Sound() {
    this->sound = NULL;
}

Sound::Sound(const Sound& orig) {
    this->sound = orig.sound;
}

Sound::Sound(const string path) {
    this->sound = Mix_LoadWAV(path.c_str());
    if (this->sound == NULL)
        throw InitializationException(Mix_GetError());
}

void Sound::load(const string path) {
    this->sound = Mix_LoadWAV(path.c_str());
    if (this->sound == NULL)
        throw InitializationException(Mix_GetError());
}

void Sound::play() {
    if (this->sound != NULL) {
        //Ver los otros dos parametros
        Mix_PlayChannel(-1, this->sound, 0);
    }

}

Sound::~Sound() {
    Mix_FreeChunk(this->sound);
}

